package com.maychat.config;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {

    @Value("${ws.port}")
    private Integer websocketPort;

    @Value("${project.folder}")
    private String projectFolder;

    @Value("${admin.emails}")
    private String adminsEmail;


    public AppConfig() {
    }

    public AppConfig(Integer websocketPort, String projectFolder, String adminsEmail) {
        this.websocketPort = websocketPort;
        this.projectFolder = projectFolder;
        this.adminsEmail = adminsEmail;
    }

    /**
     * 获取
     *
     * @return websocketPort
     */
    public Integer getWebsocketPort() {
        return websocketPort;
    }

    /**
     * 设置
     *
     * @param websocketPort
     */
    public void setWebsocketPort(Integer websocketPort) {
        this.websocketPort = websocketPort;
    }

    /**
     * 获取
     *
     * @return projectFolder
     */
    public String getProjectFolder() {
        if (StringUtils.isBlank(projectFolder) || !projectFolder.endsWith("/"))
            projectFolder = projectFolder + "/";
        return projectFolder;
    }

    /**
     * 设置
     *
     * @param projectFolder
     */
    public void setProjectFolder(String projectFolder) {
        this.projectFolder = projectFolder;
    }

    /**
     * 获取
     *
     * @return adminsEmail
     */
    public String getAdminsEmail() {
        return adminsEmail;
    }


    public String toString() {
        return "AppConfig{websocketPort = " + websocketPort + ", projectFolder = " + projectFolder + ", adminsEmail = " + adminsEmail + "}";
    }
}
